<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport" />
    <meta content="yes" name="apple-mobile-web-app-capable" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="telephone=no" name="format-detection" />
    <link rel="stylesheet" href="$!{basePath}/content/system/h5/css/ydui.css" />
    <link rel="stylesheet" href="$!{basePath}/content/system/h5/css/common.css" />
    <link rel="stylesheet" href="$!{basePath}/content/system/h5/css/style.css" />
</head>
<script src="$!{basePath}/content/system/h5/js/ydui.flexible.js"></script>
<script src="$!{basePath}/content/system/h5/js/jquery-1.9.1.min.js"></script>
<script src="$!{basePath}/content/system/h5/js/ydui.js"></script>
<script src="$!{basePath}/plug-in/plugin/webuploader/js/webuploader.js" type="text/javascript"></script>
<script src="$!{basePath}/plug-in/plugin/webuploader/js/webuploaderUtils.js" type="text/javascript"></script>
<link rel="stylesheet" href="$!{basePath}/plug-in/plugin/webuploader/css/webuploader.css" />

<body style="max-width: 750px;margin:0 auto;padding-bottom: 10%">
    <input type="hidden" value="$!{poster.id}" name="id" id="id" />
    <section class="topHead">
        <h3>海报换码</h3>
        <p>$!{user.userName}</p>
    </section>
    <div class="space"></div>
    <section class="formInput">
        <div class="inputBox clearfix">
            <div class="fl inputLeft">
                上传二维码<span class="red">*</span>
            </div>
            <div class="fl inputRight">
                <input type="hidden" name="wxGroupCode" id="wxGroupCode" value="$!{poster.wxGroupCode}">
                <div id="wxGroup"><span class="glyphicon glyphicon-picture"></span> 选择图片</div>
                <div style="width:100px; height:120px;">
                    <div style="width:100px; height:100px">
                        <img src="$!{poster.wxGroupCode}" width="100" height="100" id="wxGroup_view" />
                    </div>
                </div>
            </div>
        </div>
        <div class="inputBox clearfix">
            <div class="fl inputLeft">
                海报样式风格<span class="red">*</span>
            </div>
            <div class="fl inputRight">
                <select name="posterType" id="posterType">
                    <option value="hb04" selected="selected">紫色海报</option>
                    <option value="hb05">深蓝色海报</option>
                </select>
            </div>
        </div>
        <div class="inputBox clearfix">
            <div class="fl inputLeft">
                是否有引导页<span class="red">*</span>
            </div>
            <div class="fl inputRight">
                <select name="guide" id="guide">
                  <option value="1" #if(1==$!{poster.guide}) selected #end>有引导页</option>
                  <option value="0" #if(0==$!{poster.guide}) selected #end>无引导页</option>
                </select>
            </div>
        </div>
        <div class="inputBox clearfix">
            <div class="fl inputLeft">
                二维码分类<span class="red">*</span>
            </div>
            <div class="fl inputRight">
                <div class="clearfix">
                    <div class="fl">
                        <select name="level" id="level">
                          <option value="1" #if(1==$!{poster.level}) selected #end >群码优先</option>
                          <option value="0" #if(0==$!{poster.level}) selected #end>人码优先</option>
                        </select>
                    </div>
                    <div class="fl" style="padding-top:3%;">
                        <span style="font-size: 12px;">注:一般默认群码优先</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="inputBox clearfix mt8 bdt">
            <div class="fl inputLeft">
            个人固定码<span class="red">*</span>
            </div>
            <div class="fl inputRight">
                <input type="hidden" name="wxPersonCode" id="wxPersonCode" value="$!{poster.wxPersonCode}">
                <div id="wxPerson"><span class="glyphicon glyphicon-picture"></span> 选择图片</div>
                <div style="width:100px; height:120px;">
                    <div style="width:100px; height:100px">
                        <img src="$!{poster.wxPersonCode}" width="100" height="100" id="wxPerson_view" />
                    </div>
                </div>
            </div>
        </div>
        <div class="coundd mt10 text-center fs30" style="padding-bottom: 8%">
                当日扫码 &emsp; (<span class='red'>0</span>)&emsp;-&emsp;总扫码  &emsp;(<span class='red'>0</span>)次
&emsp;
        </div>
    </section>
    <section class="pd4" style="background: #F5F5F6;">
        <img src="$!{basePath}/content/system/h5/img/1.png" alt="" width="100%">
    </section>

    <button type="button" class="btn-block btn-primary fixbtn" onclick="okClick()">确认换码</button>
</body>
</html>
<script type="text/javascript">
    var opts={
        url:"$!{basePath}/system/back/poster/manage/doUpload.do",
        fileSizeLimit:20*1024*1024 //限制上传图片大小为0.5M
    };

    $("#wxGroup").uploader(opts,function(data){
        $("#wxGroupCode").val(data.obj);
        $("#wxGroup_view").attr("src",data.obj);
    });
    $("#wxPerson").uploader(opts,function(data){
        $("#wxPersonCode").val(data.obj);
        $("#wxPerson_view").attr("src",data.obj);
    });

    function okClick() {
        var id = $("#id").val();
        var wxGroupCode = $("#wxGroupCode").val();
        var posterType = $("#posterType").val();
        var guide = $("#guide").val();
        var level = $("#level").val();
        var wxPersonCode = $("#wxPersonCode").val();
        if(wxGroupCode == '' || wxGroupCode == null) {
            alert("群码不能为空！");
            return;
        }
        if(posterType == '' || posterType == null) {
            alert("海报风格不能为空！");
            return;
        }
        if(guide == '' || guide == null) {
            alert("是否引导不能为空！");
            return;
        }
        if(wxPersonCode == '' || wxPersonCode == null) {
            alert("个人吗不能为空！");
            return;
        }


        jQuery.ajax({
            url:"$!{basePath}/system/back/poster/manage/doEdit.do",
            type:"POST",
            dataType: "json",
            data:{
                id:id,
                wxGroupCode:wxGroupCode,
                posterType:posterType,
                guide:guide,
                level:level,
                wxPersonCode:wxPersonCode
            },
            success:function(data){
                alert("换码成功！");
                window.location.href = "/system/back/poster/manage/toMyList.do";
            },
            error:function(data) {
                alert(data.msg);
            }
        });

    }
</script>